package br.com.zeneplayer.view;

import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class ImagePanel
extends JPanel
{
	private static final long	serialVersionUID	= -2909694900462575689L;

	/**
	 * BackgroundImage.
	 */
	Image	backgroundImage;

	/**
	 * Default constructor.
	 */
	public ImagePanel()
	{
		this.initialize();
	}

	private void initialize()
	{
		URL imageUrl = ClassLoader.getSystemResource("br/com/zeneplayer/assets/imagem.jpg");
		ImageIcon imageIcon = new ImageIcon(imageUrl);
		backgroundImage = imageIcon.getImage();
		
		this.setLayout(new BorderLayout());
	}

	@Override
	protected void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		
		if (backgroundImage != null)
		{
			int height = this.getSize().height;
			int width = this.getSize().width;
			g.drawImage(backgroundImage, 0, 0, width, height, this);
			// g.drawImage(image, 0, 0, this); //original image size
		}
	}

}
